#ifndef DUALLISTMODEL_H
#define DUALLISTMODEL_H

#include <QAbstractListModel>

class DualModel : public QAbstractListModel
{
    Q_OBJECT
public:
    explicit DualModel(const QAbstractItemModel *gameModel, const QAbstractItemModel *armyModel,
                               QObject *parent = 0);

    virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const;
    virtual int rowCount (const QModelIndex &parent = QModelIndex()) const;
    virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
    
private slots:

    // Slots for the game model

    void game_headerDataChanged(Qt::Orientation orientation, int first, int last);

    void game_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
    void game_rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
    void game_rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart,
                              int sourceEnd, const QModelIndex &destinationParent,
                              int destinationRow);
    void game_rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);

    // Slots for the army model

    void army_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
    void army_rowsAboutToBeInserted(const QModelIndex &parent, int first, int last);
    void army_rowsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart,
                              int sourceEnd, const QModelIndex &destinationParent,
                              int destinationRow);
    void army_rowsAboutToBeRemoved(const QModelIndex &parent, int first, int last);

    // Common slots

    void common_modelAboutToBeReset();
    void common_modelReset();
    void common_rowsInserted();
    void common_rowsMoved();
    void common_rowsRemoved();
    
    // Not implemented

//    void p_columnsAboutToBeInserted(const QModelIndex &parent, int start, int end);
//    void p_columnsAboutToBeMoved(const QModelIndex &sourceParent, int sourceStart,
//                                  int sourceEnd, const QModelIndex &destinationParent, int destinationColumn);
//    void p_columnsAboutToBeRemoved(const QModelIndex &parent, int start, int end);
//    void p_columnsInserted(const QModelIndex &parent, int start, int end);
//    void p_columnsMoved(const QModelIndex & sourceParent, int sourceStart, int sourceEnd,
//                        const QModelIndex &destinationParent, int destinationColumn);
//    void p_columnsRemoved(const QModelIndex &parent, int start, int end);

protected:
    const QAbstractItemModel *gameModel;
    const QAbstractItemModel *armyModel;
};

#endif // DUALLISTMODEL_H
